--
-- Author: ping.wang
-- Date: 2018-09-22 13:59:24
--
-- MakeLoadingRender
--

local ClassRef = app.mvc.createRenderClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.NodeMakeLoading))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self:refresh()
end

function ClassRef:refresh()
    if self._data then
        self:setVisible( true )

        local num = tonumber(self._data)
        --self._ui.Slider:setPercent(num)
        if num >= 100 then
            self._ui.Slider:setVisible(true)
            self._ui.Image_light:setVisible(true)
        else
            self._ui.Slider:setVisible(false)
            self._ui.Image_light:setVisible(false)
        end
    else
        self:setVisible( false )
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
